package com.jiazhong.shopping.dao.impl;

import com.jiazhong.shopping.dao.DBUtil;
import com.jiazhong.shopping.dao.UserDao;
import com.jiazhong.shopping.model.User;


public class UserDaoImpl extends DBUtil implements UserDao {
    public User login(String user_name, String user_password) {
        //创建SQL语句
        String sql = "select * from tbl_user where user_name=? and user_password=?";
        //调用父类中查询的方法实现登录查询
        return super.executeQueryOne(sql,User.class,user_name,user_password);
    }

    @Override
    public void addUser(User user) {
        String sql  = "insert into tbl_user values(default,?,?,?)";
        super.executeUpdate(sql,user.getUser_name(),
                user.getUser_password(),
                user.getUser_email()
                );
    }
}
